package com.itheima.d1_char_stream;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileReaderTest1 {
    public static void main(String[] args) {
        try (
                FileReader fr = new FileReader("Day18-io-app\\src\\itheima01.txt");
                BufferedReader br = new BufferedReader(fr);
        ){
            /*int c;
            while ((c = fr.read()) != -1) {
                System.out.print((char) c);*/
                //每次读取一个字符，性能很差

                //每次读取多个字符
            /*char[] cbuf = new char[1024];
            int len;
            while ((len = br.read(cbuf)) != -1) {
                System.out.print(new String(cbuf, 0, len));
                //性能很不错
            }*/
            /*System.out.println(br.readLine());
            System.out.println(br.readLine());
            System.out.println(br.readLine());
            System.out.println(br.readLine());*/
            String line;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }
        }
         catch (Exception e) {
            e.printStackTrace();
        }


    }
}
